package com.evo.chat.admin.controller;

import com.evo.chat.admin.service.AdminReplyService;
import com.evo.chat.common.Result;
import com.evo.chat.common.ResultEnum;
import com.evo.chat.common.base.BaseController;
import com.evo.chat.common.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @author luwenzheng
 * date 2020-02-11
 */
@RestController
@RequestMapping("/mReply")
@CrossOrigin
public class ReplyController extends BaseController {

    @Autowired
    AdminReplyService service;

    @PostMapping(value = "/create")
    public Result createReply(@RequestParam(value = "wordId") Integer wordId,
                              @RequestParam(value = "reply_user") String user,
                              @RequestParam(value = "content") String content) {

        verifyToken();

        if (StringUtils.isEmpty(wordId) || StringUtils.isEmpty(content) || StringUtils.isEmpty(user)) {
            return ResultUtil.error(ResultEnum.PARAMETER_VALIDATION_ERROR);
        }

        return service.createReply(wordId, user, content);
    }

}
